﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Windows.Forms;

namespace OfficeConvert
{
    /// <summary>
    /// 将office文档转换为flash
    /// by：qnl
    /// 2013-08-22
    /// </summary>
    public class OfficeToFlash
    {
        /// <summary>
        /// 转换方法
        /// </summary>
        /// <param name="sourcePath"></param>
        /// <param name="flashPath"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static bool DoConvert(string sourcePath, string flashPath)
        {
            bool result = false;
            string pdftempfile = string.Format("{0}/pdftemp/{1}.pdf", Application.StartupPath, Guid.NewGuid());
            var tempFloder = Path.GetDirectoryName(pdftempfile);
            if (!Directory.Exists(tempFloder))
            {
                Directory.CreateDirectory(tempFloder);
            }
            result = OfficeToPdf.DoConvert(sourcePath, pdftempfile);
            if (result)
            {
                result = PdfToFlash.DoConvert(pdftempfile, flashPath);
                File.Delete(pdftempfile);
            }
            return result;
        }
    }
}
